#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef int ElemType;
typedef struct{
    ElemType *elem;
    int lenth;
}SSTable;
void InitSS(SSTable &ST,int len)
{
    ST.lenth=len;
    ST.elem=(ElemType*)malloc(sizeof(ElemType)*ST.lenth);
    srand(time(NULL));
    int i=0;
    while(i<len)
    {
        ST.elem[i]=rand()%100;
        i++;
    }
}
void printSStable(SSTable ST)
{
    int i=0;
    for(i;i<ST.lenth;i++)
    {
        printf("%3d",ST.elem[i]);
    }
    printf("\n");
}
int partation(ElemType *A,int low,int high)
{
    ElemType piovt=A[low];//拿最左边的作为分隔值存下来
    while(low<high) {
        while (low < high && A[high] >= piovt)
            high--;
        A[low]=A[high];
        while(low<high&&A[low]<=piovt)
            low++;
        A[high]=A[low];
    }
    A[low]=piovt;
    return low;
}
void QuickSort(ElemType *A,int low,int high)
{
    if (low<high)
    {
        int pivot_pos=partation(A,low,high);
        QuickSort(A,low,pivot_pos-1);
        QuickSort(A,pivot_pos+1,high)

        ;
    }
}
int main()
{
    SSTable ST;
    InitSS(ST,10);
    printSStable(ST);
    QuickSort(ST.elem,0,9);
    printSStable(ST);
    return 0;
}